package com.cslg.ac.demo.entity.user.team;

import com.cslg.ac.demo.util.communicate.EmailUtil;
import com.cslg.ac.demo.util.string.StringUtil;

import java.util.Date;
import java.util.regex.Pattern;

public class TeamInfo {
    private Integer id;
    private String name;
    private String nature;
    private String address;
    private String codeNumber;
    private String email;
    private Integer grade;
    private String etime;
    private String oPhone;
    private String introduction;
    private String image;
    private String proof;


//    public boolean longAndLatValid(){
//        boolean notValid = (longitude != null && latitude != null ) &&
//                (longitude < -90 || longitude > 90) &&
//                (latitude < 180 || latitude > 180);
//        if(notValid){
//            return false;
//        }
//        return true;
//    }

    public boolean changeValid(int tNameLength,int addressLength,int natureLength,int introLength){
        if(StringUtil.haveNullOrEmpty(name,nature,introduction,address)){
            return false;
        }
        if(StringUtil.lengthAbove(name,tNameLength) || StringUtil.lengthAbove(address,addressLength) ||
                StringUtil.lengthAbove(introduction,introLength) || StringUtil.lengthAbove(nature,natureLength)){
            return false;
        }
        String regex = "^[0-9]{4}\\-[0-9]{2}\\-[0-9]{2}";
        if(!Pattern.matches(regex,etime)){
            return false;
        }
        return true;
    }

    public boolean addValid(int nameLength,int natureLength,int addressLength,int codeNumberLength,int phoneLength){
        if(StringUtil.haveNullOrEmpty(name,nature,address,email,oPhone)){
            return false;
        }
        if(StringUtil.lengthAbove(name,nameLength) || StringUtil.lengthAbove(nature,natureLength) || StringUtil.lengthAbove(address,addressLength) ||
                StringUtil.lengthAbove(oPhone,phoneLength)){
            return false;
        }
        if(!StringUtil.haveNullOrEmpty(codeNumber) && StringUtil.lengthAbove(codeNumber,codeNumberLength)){
            return false;
        }
        if(!EmailUtil.isMailAddress(email)){
            return false;
        }
        String regex = "^[0-9]{4}\\-[0-9]{2}\\-[0-9]{2}";
        if(StringUtil.haveNullOrEmpty(etime) || !Pattern.matches(regex,etime)){
            return false;
        }
        return true;
    }


    public TeamInfo() {
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNature() {
        return nature;
    }

    public void setNature(String nature) {
        this.nature = nature;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCodeNumber() {
        return codeNumber;
    }

    public void setCodeNumber(String codeNumber) {
        this.codeNumber = codeNumber;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getGrade() {
        return grade;
    }

    public void setGrade(Integer grade) {
        this.grade = grade;
    }

    public String getoPhone() {
        return oPhone;
    }

    public void setoPhone(String oPhone) {
        this.oPhone = oPhone;
    }


    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }


    public String getProof() {
        return proof;
    }

    public void setProof(String proof) {
        this.proof = proof;
    }

    public String getEtime() {
        return etime;
    }

    public void setEtime(String etime) {
        this.etime = etime;
    }


    @Override
    public String toString() {
        return "TeamInfo{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", nature='" + nature + '\'' +
                ", address='" + address + '\'' +
                ", codeNumber='" + codeNumber + '\'' +
                ", email='" + email + '\'' +
                ", grade=" + grade +
                ", etime='" + etime + '\'' +
                ", oPhone='" + oPhone + '\'' +
                ", introduction='" + introduction + '\'' +
                ", image='" + image + '\'' +
                ", proof='" + proof + '\'' +
                '}';
    }
}
